package com.estagio.dao;

import java.util.List;

import org.hibernate.Session;

import util.HibernateUtil;


public abstract class Dao<T> {
	
	private Session sessao;	

	public Session getSessao() {
		return sessao;
	}

	public void setSessao(Session sessao) {
		this.sessao = sessao;
	}

	public void save(Object obj) {
		this.sessao = HibernateUtil.getSession().getCurrentSession();
		this.sessao.save(obj);

	}
	
	public void update(Object obj) {
		this.sessao = HibernateUtil.getSession().getCurrentSession();
		this.sessao.update(obj);
		this.sessao.flush();
		this.sessao.refresh(obj);
	}
	
	public void delete(Object obj) {
		this.sessao.delete(obj);
	}	
	
	public abstract List<T> find(Object obj);
	public abstract List<T> findByPrimaryKey(Object obj);
	public abstract List<T> list();


}
